function sigma = optSigma(X)
    N = size(X,1);
    dist = EuDist2(X,X); 
    sigma = mean(mean(dist));